home *** CD-ROM | disk | FTP | other *** search
- function variablesEasy()
- {
- _root.popInc = 5;
- _root.levelUpAt = 5000;
- _root.populationIncreaseRate = 250;
- _root.enemySpeed = 0.5;
- _root.enemySpeedInc = 0.04;
- _root.enemyArmor = 3;
- _root.enemyArmorInc = 0.3;
- _root.laserSpeed = 15;
- _root.powerupRate = 1000;
- _root.powerupRateDec = 40;
- _root.powerupSpeed = 1;
- _root.powerupSpeedInc = 0;
- _root.popPowerup = 2000;
- _root.missileRate = 500;
- _root.maxMissileRate = 100;
- _root.missileRateInc = 15;
- _root.maxBombs = 1;
- _root.maxBombsInc = 0.5;
- _root.boss1Armor = 10;
- _root.boss1Speed = 0.6;
- _root.boss2Armor = 10;
- _root.boss2Speed = 0.6;
- _root.boss2Immunity = 0.4;
- _root.boss3Armor = 10;
- _root.boss3Speed = 0.6;
- _root.boss3Invisible = 0.4;
- _root.boss3Alpha = 25;
- }
- function variablesHard()
- {
- _root.popInc = 5;
- _root.levelUpAt = 5000;
- _root.populationIncreaseRate = 250;
- _root.enemySpeed = 0.7;
- _root.enemySpeedInc = 0.05;
- _root.enemyArmor = 5;
- _root.enemyArmorInc = 0.3;
- _root.laserSpeed = 15;
- _root.powerupRate = 1000;
- _root.powerupRateDec = 50;
- _root.powerupSpeed = 2;
- _root.powerupSpeedInc = 0;
- _root.popPowerup = 2000;
- _root.missileRate = 500;
- _root.maxMissileRate = 100;
- _root.missileRateInc = 25;
- _root.maxBombs = 1;
- _root.maxBombsInc = 0.5;
- _root.boss1Armor = 15;
- _root.boss1Speed = 0.8;
- _root.boss2Armor = 15;
- _root.boss2Speed = 0.8;
- _root.boss2Immunity = 0.5;
- _root.boss3Armor = 15;
- _root.boss3Speed = 0.8;
- _root.boss3Invisible = 0.5;
- _root.boss3Alpha = 15;
- }
- function levelUpFunct()
- {
- enemySpeed += enemySpeedInc;
- enemyArmor += enemyArmorInc;
- powerupRate += powerupRateDec;
- powerupSpeed += powerupSpeedInc;
- missileRate + missileRateInc <= maxMissileRate ? (missileRate += missileRateInc) : (missileRate = maxMissileRate);
- maxBombs += maxBombsInc;
- trace("enemySpeed = " + enemySpeed + "\nenemyArmor = " + enemyArmor + "\npowerupRate = " + powerupRate + "\npowerupSpeed = " + powerupSpeed + "\nmissileRate = " + missileRate + "\nmaxBombs = " + maxBombs);
- }
- stop();
- if(_root.dif == "Easy")
- {
- _root.variablesEasy();
- }
- else
- {
- _root.variablesHard();
- }
- _root.pop = 0;
- _root.ammo = 20;
- var powerupOnStage = false;
- var timerNew = 0;
- var level = 1;
- var levelStr = "LEVEL " + level;
- var nextBoss = 1;
- var gamePaused = false;
- var pKeyDown = false;
- var gameOver = false;
- var bombsOnStage = new Array();
- var bosses = new Array(10000,25000,50000);
- var powerupsArray = new Array("powerup1","powerup2");
- _root.createEmptyMovieClip("buildings",_root.getNextHighestDepth());
- Mouse.hide();
- _root.attachMovie("crosshair","crosshair",_root.getNextHighestDepth());
- _root.crosshair.startDrag(true);
- _root.crosshair.onEnterFrame = function()
- {
- this._rotation += 3;
- this.swapDepths(_root.getNextHighestDepth());
- };
- onLoad = function()
- {
- _root.ball._y = _root.gun._y;
- _root.ball._x = _root.gun._x;
- };
- var bc = 1000;
- var ec = 1000;
- _root.mousedown = false;
- onMouseDown = function()
- {
- if(!gamePaused)
- {
- _root.mousedown = true;
- }
- };
- onMouseUp = function()
- {
- if(!gamePaused)
- {
- Mouse.hide();
- _root.mousedown = false;
- _root.cooldown = 0;
- }
- };
- _root.onEnterFrame = function()
- {
- if(Key.isDown(80) && !pKeyDown && !gameOver)
- {
- pKeyDown = true;
- !gamePaused ? (gamePaused = true) : (gamePaused = false);
- }
- if(!Key.isDown(80))
- {
- pKeyDown = false;
- }
- if(!gamePaused)
- {
- if(!gameOver)
- {
- pop += popInc;
- }
- if(_root.pop >= level * levelUpAt && _root.pop > 0)
- {
- level++;
- levelUpMC.gotoAndPlay(2);
- levelStr = "LEVEL " + level;
- levelUpFunct();
- dep = buildings.getNextHighestDepth();
- mc = buildings.attachMovie("build1","strM" + dep,dep);
- mc._x = Math.random() * 550;
- mc._y = 350 + Math.random() * 50;
- }
- if(random(powerupRate) == 0)
- {
- _root.attachMovie(powerupsArray[random(2)],"Powerup",_root.getNextHighestDepth(),{_x:random(500),_y:-150,speed:_root.powerupSpeed});
- Powerup.onEnterFrame = function()
- {
- if(!gamePaused)
- {
- this._y += this.speed;
- if(this._y > Stage.height + 50)
- {
- _root.powerupOnStage = false;
- this.removeMovieClip();
- }
- }
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- };
- powerupOnStage = true;
- }
- if(_root.pop >= bosses[0] && bosses.length > 0 || _root.pop > 50000 && _root.pop % 10000 == 0)
- {
- _root.attachMovie("boss" + nextBoss,"enemy1" + ec,_root.getNextHighestDepth(),{_x:200,_y:-50,armor:_root["boss" + nextBoss + "Armor"],speed:_root["boss" + nextBoss + "Speed"],number:ec,init:false});
- _root.bombsOnStage.push(ec);
- if(nextBoss == 1)
- {
- _root["enemy1" + ec].onEnterFrame = function()
- {
- if(_root.gamePaused)
- {
- this.stop();
- }
- else
- {
- this.play();
- }
- if(!_root.gamePaused)
- {
- this._y += this.speed;
- if(this._y > _root.gun._y && this.armor > 0)
- {
- _root.gameOver = true;
- _root.g_over.play();
- _root.g_over.swapDepths(_root.getNextHighestDepth());
- }
- if(this.armor <= 0)
- {
- this.explode.play();
- this.inside._visible = false;
- i = 0;
- while(i <= _root.bombsOnStage.length)
- {
- if(_root.bombsOnStage[i] == this.number)
- {
- _root.bombsOnStage.splice(i,1);
- break;
- }
- i++;
- }
- if(this.explode._currentframe > 24)
- {
- this.removeMovieClip();
- }
- }
- }
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- };
- }
- else if(nextBoss == 2)
- {
- _root["enemy1" + ec].onEnterFrame = function()
- {
- if(!this.init)
- {
- this.init = true;
- this.immune = false;
- this.Loop = 0;
- this.loopOrg = 100;
- this.immunityTime = Math.round(this.loopOrg * _root.boss2Immunity);
- }
- if(_root.gamePaused)
- {
- this.stop();
- }
- else
- {
- this.play();
- }
- if(!_root.gamePaused)
- {
- this._y += this.speed;
- if(this.Loop >= this.loopOrg)
- {
- this.Loop = 0;
- }
- else
- {
- this.Loop = this.Loop + 1;
- }
- if(this.Loop < this.loopOrg - this.immunityTime)
- {
- this.inside.gotoAndStop("notImmune");
- this.immune = false;
- }
- else
- {
- this.immune = true;
- this.inside.gotoAndStop("immune");
- }
- if(this._y > _root.gun._y && this.armor > 0)
- {
- _root.gameOver = true;
- _root.g_over.play();
- _root.g_over.swapDepths(_root.getNextHighestDepth());
- }
- if(this.armor <= 0)
- {
- this.explode.play();
- this.inside._visible = false;
- i = 0;
- while(i <= _root.bombsOnStage.length)
- {
- if(_root.bombsOnStage[i] == this.number)
- {
- _root.bombsOnStage.splice(i,1);
- break;
- }
- i++;
- }
- if(this.explode._currentframe > 24)
- {
- this.removeMovieClip();
- }
- }
- }
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- };
- }
- else if(nextBoss == 3)
- {
- _root["enemy1" + ec].onEnterFrame = function()
- {
- if(_root.gamePaused)
- {
- this.stop();
- }
- else
- {
- this.play();
- }
- if(!this.init)
- {
- this.init = true;
- this.immune = false;
- this.Loop = 0;
- this.loopOrg = 100;
- this.immunityTime = Math.round(this.loopOrg * _root.boss3Invisible);
- }
- if(!_root.gamePaused)
- {
- this._y += this.speed;
- if(this.Loop >= this.loopOrg)
- {
- this.Loop = 0;
- }
- else
- {
- this.Loop = this.Loop + 1;
- }
- if(this.Loop < this.loopOrg - this.immunityTime)
- {
- this._alpha = 100;
- this.immune = false;
- }
- else
- {
- this._alpha = _root.boss3Alpha;
- this.immune = true;
- }
- if(this._y > _root.gun._y && this.armor > 0)
- {
- _root.gameOver = true;
- _root.g_over.play();
- _root.g_over.swapDepths(_root.getNextHighestDepth());
- }
- if(this.armor <= 0)
- {
- this.explode.play();
- this.inside._visible = false;
- i = 0;
- while(i <= _root.bombsOnStage.length)
- {
- if(_root.bombsOnStage[i] == this.number)
- {
- _root.bombsOnStage.splice(i,1);
- break;
- }
- i++;
- }
- if(this.explode._currentframe > 24)
- {
- this.removeMovieClip();
- }
- }
- }
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- };
- }
- _root.bosses.shift();
- if(nextBoss < 3)
- {
- nextBoss++;
- }
- ec++;
- if(ec > 1100)
- {
- ec = 1000;
- }
- }
- if(random(missileRate) == 0 && _root.bombsOnStage.length <= _root.maxBombs)
- {
- _root.attachMovie("enemy1","enemy1" + ec,_root.getNextHighestDepth(),{_x:random(500),_y:-50,armor:_root.enemyArmor,number:ec});
- _root.bombsOnStage.push(ec);
- _root["enemy1" + ec].onEnterFrame = function()
- {
- if(!_root.gamePaused)
- {
- this._y += _root.enemySpeed;
- if(this._y > _root.gun._y && this.armor > 0)
- {
- _root.gameOver = true;
- _root.g_over.play();
- _root.g_over.swapDepths(_root.getNextHighestDepth());
- }
- if(this.armor <= 0)
- {
- this.explode.play();
- this.inside._visible = false;
- i = 0;
- while(i <= _root.bombsOnStage.length)
- {
- if(_root.bombsOnStage[i] == this.number)
- {
- _root.bombsOnStage.splice(i,1);
- break;
- }
- i++;
- }
- if(this.explode._currentframe > 24)
- {
- this.removeMovieClip();
- }
- }
- }
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- };
- ec++;
- if(ec > 1100)
- {
- ec = 1000;
- }
- }
- if(_root.cooldown > 0)
- {
- _root.cooldown = _root.cooldown - 1;
- }
- if(Key.isDown(32) && hud.rload._currentframe == 1)
- {
- hud.rload.gotoAndPlay(2);
- }
- if(_root.mousedown == true && _root.ammo > 0 && _root.cooldown == 0 && hud.rload._currentframe == 1)
- {
- _root.cooldown = 10;
- _root.ammo = _root.ammo - 1;
- _root.gun.gotoAndPlay(2);
- bc++;
- if(bc > 1100)
- {
- bc = 1000;
- }
- _root.attachMovie("bullet","bullet" + bc,_root.getNextHighestDepth(),{_x:_root.gun._x,_y:_root.gun._y,damage:1,spd:_root.laserSpeed,_rotation:_root.gun._rotation});
- _root["bullet" + bc].onEnterFrame = function()
- {
- if(_root.gameOver)
- {
- this.removeMovieClip();
- }
- if(!_root.gamePaused)
- {
- if(_rotation > 180)
- {
- this._y += this.spd * Math.cos(0.017453292519943295 * this._rotation);
- this._x -= this.spd * Math.sin(0.017453292519943295 * this._rotation);
- }
- else
- {
- this._y -= this.spd * Math.cos(0.017453292519943295 * this._rotation);
- this._x += this.spd * Math.sin(0.017453292519943295 * this._rotation);
- }
- if(_root.Powerup.inside.hitTest(this._x,this._y,true))
- {
- if(_root.Powerup.powerupKind == "bomb")
- {
- i = 0;
- while(i <= _root.bombsOnStage.length - 1)
- {
- _root["enemy1" + _root.bombsOnStage[i]].armor = 0;
- i++;
- }
- }
- else
- {
- _root.pop += _root.popPowerup;
- }
- _root.Powerup.removeMovieClip();
- _root.powerupOnStage = false;
- this.removeMovieClip();
- }
- i = 0;
- while(i <= _root.bombsOnStage.length - 1)
- {
- currEnemy = _root["enemy1" + _root.bombsOnStage[i]];
- if(currEnemy.inside.hitTest(this))
- {
- if(currEnemy.inside.hitTest(this._x,this._y,true))
- {
- if(!currEnemy.immune || currEnemy.immune == "undefined")
- {
- currEnemy.armor--;
- currEnemy.sexplode.play();
- }
- if(currEnemy._alpha == 100)
- {
- this.removeMovieClip();
- }
- break;
- }
- }
- i++;
- }
- if(this._x > Stage.width || this._x < 0 || this._y < 0 || this._y > Stage.height)
- {
- this.removeMovieClip();
- }
- }
- };
- }
- }
- };
-